<?php

namespace App\Http\Controllers\Internal\OpenShop;

use App\Http\Controllers\BaseController;
use App\Http\Validate\OpenShop\InvestmentPromotion\OrderValidate;
use App\Service\OpenShop\OrderService;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Validation\ValidationException;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;

class SignOrderController extends BaseController
{
    /**
     * 更换经理
     *
     * @param Request $request
     * @param int $id
     * @return JsonResponse
     * @throws ContainerExceptionInterface
     * @throws NotFoundExceptionInterface
     * @throws ValidationException
     */
    public function changeManager(Request $request): JsonResponse
    {
        $shopCode = $request->get('shopCode');
        $type     = $request->get('type');
        $uid      = $request->get('uid');
        $uname    = $request->get('uname');

        if (empty($shopCode) || empty($type) || empty($uid) || empty($uname)) {
            return $this->fail(0);
        }

        OrderService::changeManagerInternal($shopCode, $type, $uid, $uname);
        return $this->success();
    }
}
